package it.aqquadro;

import it.aqquadro.arex.Arex;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.JsonObject;

public class RaimondRex extends Arex {

	private JsonObject jsonResponse;

	public RaimondRex(HttpServletRequest req, HttpServletResponse resp) {
		super(req, resp);
		
		this.jsonResponse = new JsonObject();
		
		this.jsonResponse.addProperty("classname", this.getClass().getSimpleName());
		
		this.jsonResponse.addProperty("pathInfo", this.req.getPathInfo());
		
		this.jsonResponse.addProperty("method", this.req.getMethod());				
		
		this.jsonResponse.add("requestBody", this.loadGSONRequestBody());
	}

	@Override
	public void get() throws IOException {		
		this.writeJSON( jsonResponse.toString() );
	}

	@Override
	public void post() throws IOException {		
		get();
	}

	@Override
	public void put() throws IOException {
		get();
	}

	@Override
	public void delete() throws IOException {
		get();
	}

	@Override
	public void head() throws IOException {
		get();
	}

	@Override
	public void options() throws IOException {
		get();
	}

	@Override
	public void trace() throws IOException {
		get();
	}
}